# _*_ coding utf-8 _*_
# FILENAME：.py
# DESCRIPTION: 配置文件工具类
# AUTH: ZB
# DATE: 2022/6/2 10:00 下午

# 导入模块
import configparser
import os
import sys

# 配置文件路径
cfg_path = os.path.dirname(os.path.realpath(sys.argv[0])) + '/config.properties'


# 读取文件
def _read_config():
    config = configparser.ConfigParser()
    config.read(cfg_path, encoding='utf-8')
    return config


# 读取数据库配置
def read_db_config(key=None):
    config = _read_config()
    if key:
        return config.get('database', key)
    else:
        return config.items('database')


# 读取性能配置
def read_performance_config(key=None):
    config = _read_config()
    if key:
        return config.get('performance', key)
    else:
        return config.items('performance')
